package com.java.simple.study.jvm.gc.gcroot;

/**
 * @author zhoujunlin
 * @date 2022年11月07日 11:43
 * @desc -Xms256m -Xmx256m -XX:+PrintGCDetails -XX:PretenureSizeThreshold=15m
 */
public class LocalVarGC {

    public void localVarGC1() {
        // 10MB
        byte[] buffer = new byte[10 * 1024 * 1024];
        System.gc();
    }

    public void localVarGC2() {
        byte[] buffer = new byte[10 * 1024 * 1024];
        buffer = null;
        System.gc();
    }

    public void localVarGC3() {
        {
            byte[] buffer = new byte[10 * 1024 * 1024];
        }
        System.gc();
    }

    public void localVarGC4() {
        {
            byte[] buffer = new byte[10 * 1024 * 1024];
        }
        int value = 10;
        System.gc();
    }

    public void localVarGC5() {
        localVarGC1();
        System.gc();
    }

    public static void main(String[] args) {
        LocalVarGC localVarGC = new LocalVarGC();
//        localVarGC.localVarGC1();
//        localVarGC.localVarGC2();
//        localVarGC.localVarGC3();
//        localVarGC.localVarGC4();
        localVarGC.localVarGC4();
    }

}
